package git.bankview.sl.report;

import java.util.*;
import java.sql.Connection;
import java.sql.SQLException;

public class JRParameterMapAdapter extends HashMap
{
	private ConnectionValueEventListener m_oConnListener = null;
	
	public JRParameterMapAdapter(Map source, ConnectionValueEventListener listener)
	{
		System.out.println(source);
		m_oConnListener = listener;
	}
	
	public Object put(Object key, Object value)
	{
		Object r = super.put(key, value);
		
		if ("REPORT_CONNECTION".equals(key))
		{
			try
			{
				m_oConnListener.onConnectionValue(new JRRuntimeUtil(this, (Connection)value));
			}
			catch(SQLException e)
			{
				e.printStackTrace(System.err);
				throw new RuntimeException("Database Access Error", e);
			}
			catch(Exception e)
			{
				e.printStackTrace(System.err);
				throw new RuntimeException("System Error", e);
			}
		}
		
		return r;
	}
}
